<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="React"></div>

<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>

<!-- jsx转为js -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>

<script type="text/babel">

    // 最小粒度是标签
    class Time extends React.Component {

        // 初始化状态
        state = {date: new Date()}

        // 组件将要挂载
        componentDidMount() {
            setInterval(() => {
                this.setState({
                    date: new Date()
                });
            }, 1000)
        }

        render() {
            return (
                    <div>
                        <h1>hello</h1>
                        <input type="text"/>
                        <span>
                            现在是:{this.state.date.toTimeString()}
                            <input type="text"/>
                        </span>
                    </div>
            )
        }
    }

    ReactDOM.render(<Time/>, document.getElementById("React"))
</script>
</body>
</html>